Conventionally, when a JPEG compression file is generated in a JPEG-compression-file device, the file size of the generated JPEG compression file is required to be equal to a predetermined file size designated in advance.
In generating JPEG compression files by compressing image data, quantization tables are used. However, if fixed tables are adopted as the quantization tables, more than twice the difference in the file size of the generated JPEG compression files easily arises between simple image data and complicated image data.
Therefore, as a conventional technology, a technology is described in the patent document below, in which a reference quantization table is prepared in advance, which is converted in accordance with the type of the image data to be compressed, and the image data compression process is performed using the converted quantization table.
Japanese Patent Laid-Open No. 66004/1998
The conventional technology is a technology in which, in order to get a JPEG compression file of a predetermined file size, a portion of image data before compression is once JPEG-compressed, and, given that the size of the resulting compressed data is an evaluation value, a quantization table for JPEG-compressing the whole image data is calculated based on the evaluation value.
Specifically, when a portion of data is JPEG-compressed, a fixed quantization table prepared in advance is used. Next, a resulting data size in a case in which a portion of image data is JPEG-compressed according to the fixed quantization table is calculated as an evaluation value H.
Next, based on the evaluation value H, a factor q of the quantization table for JPEG-compressing the whole image data is calculated according to the calculation formula q=M×H−N. Here, M and N are predetermined coefficients, which are determined in advance by experiment for each of desired file sizes.
In addition, in the embodiment of the conventional technology described above, the coefficient M, in the calculation formula q=M×H−N, tends to increase, as the evaluation value H increases. Therefore, a method of switching the coefficient M between two values M1 and M2 in accordance with the evaluation value H is adopted.